﻿package com.kuanter.kuanterauto.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.kuanter.kuanterauto.R;
import com.kuanter.kuanterauto.baseui.BaseActivity_NoBar;
/**
 * 自定义基类
 * @author kuanter
 *
 */
public abstract class WuyangBaseActivity extends BaseActivity_NoBar{
	public static String TAG = "WuyangBaseActivity";
	protected TextView headerTitle;
	protected Button headerLeft;
	protected Button headerRight;
	protected Intent intent = new Intent();
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.initHeaderControlView();
	}
	//初始化控件
	protected void initHeaderControlView(){
		headerTitle = (TextView) this.findViewById(R.id.header_title);
		headerLeft = (Button)this.findViewById(R.id.header_left);
		headerRight = (Button)this.findViewById(R.id.header_right);
	}
	protected abstract void setHeaderControlViewText();
	protected abstract void initBodyControlView();
	protected abstract void registerListener();
	protected abstract void setBodyControlViewText();
	protected abstract void getControlViewText();
	//header的标题内容配置
	protected void setHeaderTitleText(TextView textView,String strTitle){
		if(null == textView&&null == strTitle){
			Log.e(TAG, "请查询initControlView()方法和传入的参数是否有误！！");
		}else{
				textView.setText(strTitle);
		}
	}
	//left选择文本配置
	protected void setHeaderLeftText(Button BtnLeft,String strLeftBtn) {
		if(null == BtnLeft&&null == strLeftBtn){
			Log.e(TAG, "请查询initControlView()方法和传入的参数是否有误！！");
		}else{
			if(null == strLeftBtn){
				BtnLeft.setVisibility(View.GONE);
			}else{
				BtnLeft.setText(strLeftBtn);
			}
		}
	}
	//right选择文本配置
	protected void setHeaderRightText(Button BtnRight,String strRightBtn) {
		if(null == BtnRight&&null == strRightBtn){
			Log.e(TAG, "请查询initControlView()方法和传入的参数是否有误！！");
		}else{
			if(null == strRightBtn){
				BtnRight.setVisibility(View.GONE);
			}else{
				BtnRight.setText(strRightBtn);
			}
		}
	}
	
	public void showToast(String text){
		Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
	}
	
	protected void startMyActivity(Activity currentActivity ,Class<?> cls) {
		intent.setClass(currentActivity, cls);
		currentActivity.startActivity(intent);
	}
	
}
